<?php 
defined('IN_TS') or die('Access Denied.'); 

function newgift(){
	global $db;
	//最新福利
	if( $GLOBALS['TS_USER']!=''){
		$mylink = '&link='.$GLOBALS['TS_USER']['userid'];
	}
	$arrGifts = aac('gift')->findAll('gift',
		'isaudit=0 and status=0'
	,'addtime desc','',5);

	if (count($arrGifts) > 0) {
		$userids = array_column($arrGifts, "userid");
		$users = aac('user')->getUsers($userids);

		$giftTypes = aac('gift')->getGiftTypes();
	}

	
	foreach($arrGifts as $key=>$item){

		    $arrGift[] = $item;
			$arrGift[$key]['title']=tsTitle($item['title']);
			$arrGift[$key]['user'] = $users[$item["userid"]];
			$arrGift[$key]['type'] = $giftTypes[$item['typeid']];

		   }

	include template('newgift','newgift');
	
}

function newgift_css(){

	echo '<link href="'.SITE_URL.'plugins/home/newgift/style.css" rel="stylesheet" type="text/css" />';

}

addAction('home_index_left','newgift');
addAction('pub_header_top','newgift_css');